﻿@{
    ViewBag.Title = "错误提示配置列表页";
    Layout = "~/Views/Shared/_Index.cshtml";
}

<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
            <a class="btn btn-primary" onclick="btn_add()"><i class="fa fa-plus"></i>新建</a>
        </div>
        <div class="btn-group">
            <a class="btn btn-primary" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改</a>
        </div>
        <div class="btn-group">
            <a class="btn btn-primary" onclick="btn_delete()"><i class="fa fa-pencil-square-o"></i>删除</a>
        </div>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="编码/内容" style="width: 180px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>

<script>
    $(function () {
        initControl();
        gridList();
    });
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            postData: {},
            url: "/SystemManage/SysFailedCodeMessageMapp/GetPagintionGridJson",
            height: $(window).height() - 128,
            colModel: [
                { label: "Id", name: "Id", width: 100, align: 'left', key: true, hidden: true },
                { label: "编码", name: "code", width: 450, align: 'left' },
                { label: "内容", name: "msg", width: 350, align: 'left', sortable: false },
                { label: "排序", name: "px", width: 100, align: 'left' },
                { label: "创建时间", name: "CreateTime", width: 100, align: 'left', formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' } },
            ],
            rowNum: 10,
            pager: "#gridPager",
            sortname: 'isnull(px, 99999999), CreateTime desc',
            viewrecords: true,
        });
        $("#btn_search").click(function () {
            $("#gridList").jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val() }, page: 1
            }).trigger('reloadGrid');
        });
    }

    function initControl() {

    }

    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "新增数据",
            url: "/SystemManage/SysFailedCodeMessageMapp/Form",
            width: "700px",
            height: "440px",
            callBack: function (iframeId) {
                $.currentWindow(iframeId).AcceptClick(function () {
                    $("#gridList").resetSelection();
                    $("#gridList").trigger("reloadGrid");
                });
            }
        });
    }

    function btn_edit() {
        var keyValue = $("#gridList").jqGridRowValue().Id;
        if (!!!keyValue) {
            $.modalAlert("请选中一条信息", 'warning');
            return;
        }
        $.modalOpen({
            id: "Form",
            title: "修改数据",
            url: "/SystemManage/SysFailedCodeMessageMapp/Form?keyValue=" + keyValue,
            width: "700px",
            height: "440px",
            callBack: function (iframeId) {
                $.currentWindow(iframeId).AcceptClick(function () {
                    $("#gridList").resetSelection();
                    $("#gridList").trigger("reloadGrid");
                });
            }
        });
    }

    function btn_delete() {
        var keyValue = $("#gridList").jqGridRowValue().Id;
        if (!!!keyValue) {
            $.modalAlert("请选中一条信息", 'warning');
            return;
        }
        $.deleteForm({
            url: "/SystemManage/SysFailedCodeMessageMapp/DeleteForm",
            param: { keyValue: keyValue },
            success: function () {
                $("#gridList").resetSelection();
                $("#gridList").trigger("reloadGrid");
            }
        });
    }

</script>